using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Easislides
{
	public class FrmEditBibleItem : Form
	{
		private IContainer components = null;
		private GroupBox groupBox1;
		private Button BtnCancel;
		private Button BtnOK;
		private Label label3;
		private ComboBox BibleVersionsRegion2;
		private Label label2;
		private Label label1;
		private ComboBox BibleVersionsRegion1;
		private TextBox Title;
		private string InIDStringFirstPart;
		private string InIDString;
		private int InRegion1;
		private int InRegion2;
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.BibleVersionsRegion2 = new System.Windows.Forms.ComboBox();
            this.BibleVersionsRegion1 = new System.Windows.Forms.ComboBox();
            this.Title = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.BtnCancel = new System.Windows.Forms.Button();
            this.BtnOK = new System.Windows.Forms.Button();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.BibleVersionsRegion2);
            this.groupBox1.Controls.Add(this.BibleVersionsRegion1);
            this.groupBox1.Controls.Add(this.Title);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Location = new System.Drawing.Point(12, 12);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(379, 119);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Change Bible Versions";
            // 
            // BibleVersionsRegion2
            // 
            this.BibleVersionsRegion2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.BibleVersionsRegion2.FormattingEnabled = true;
            this.BibleVersionsRegion2.Location = new System.Drawing.Point(100, 81);
            this.BibleVersionsRegion2.Name = "BibleVersionsRegion2";
            this.BibleVersionsRegion2.Size = new System.Drawing.Size(261, 21);
            this.BibleVersionsRegion2.TabIndex = 4;
            // 
            // BibleVersionsRegion1
            // 
            this.BibleVersionsRegion1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.BibleVersionsRegion1.FormattingEnabled = true;
            this.BibleVersionsRegion1.Location = new System.Drawing.Point(100, 54);
            this.BibleVersionsRegion1.Name = "BibleVersionsRegion1";
            this.BibleVersionsRegion1.Size = new System.Drawing.Size(261, 21);
            this.BibleVersionsRegion1.TabIndex = 2;
            // 
            // Title
            // 
            this.Title.BackColor = System.Drawing.SystemColors.Window;
            this.Title.Location = new System.Drawing.Point(51, 28);
            this.Title.Name = "Title";
            this.Title.ReadOnly = true;
            this.Title.Size = new System.Drawing.Size(310, 20);
            this.Title.TabIndex = 0;
            this.Title.WordWrap = false;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(8, 57);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(91, 13);
            this.label2.TabIndex = 1;
            this.label2.Text = "Region 1 Version:";
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(8, 84);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(91, 13);
            this.label3.TabIndex = 3;
            this.label3.Text = "Region 2 Version:";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(8, 31);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(30, 13);
            this.label1.TabIndex = 5;
            this.label1.Text = "Title:";
            // 
            // BtnCancel
            // 
            this.BtnCancel.Location = new System.Drawing.Point(213, 137);
            this.BtnCancel.Name = "BtnCancel";
            this.BtnCancel.Size = new System.Drawing.Size(80, 24);
            this.BtnCancel.TabIndex = 2;
            this.BtnCancel.Text = "Cancel";
            this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
            // 
            // BtnOK
            // 
            this.BtnOK.Location = new System.Drawing.Point(117, 137);
            this.BtnOK.Name = "BtnOK";
            this.BtnOK.Size = new System.Drawing.Size(80, 24);
            this.BtnOK.TabIndex = 1;
            this.BtnOK.Text = "OK";
            this.BtnOK.Click += new System.EventHandler(this.BtnOK_Click);
            // 
            // FrmEditBibleItem
            // 
            this.AcceptButton = this.BtnOK;
            this.ClientSize = new System.Drawing.Size(403, 173);
            this.Controls.Add(this.BtnCancel);
            this.Controls.Add(this.BtnOK);
            this.Controls.Add(this.groupBox1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "FrmEditBibleItem";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Edit Bible Item";
            this.Load += new System.EventHandler(this.FrmEditBibleItem_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.ResumeLayout(false);

		}
		public FrmEditBibleItem()
		{
			this.InitializeComponent();
		}
		private void FrmEditBibleItem_Load(object sender, EventArgs e)
		{
			this.Title.Text = gf.EditBible_Title;
			this.LoadBibleList(ref this.BibleVersionsRegion1);
			this.LoadBibleList(ref this.BibleVersionsRegion2);
			this.InIDString = gf.EditBible_IDString;
			gf.EditBible_IDString = "";
			this.InIDStringFirstPart = gf.ExtractOneInfo(ref this.InIDString, ';');
			this.InRegion1 = gf.LookUpBibleVersionNumber(gf.ExtractOneInfo(ref this.InIDString, ';')) + 1;
			this.InRegion2 = gf.LookUpBibleVersionNumber(gf.ExtractOneInfo(ref this.InIDString, ';')) + 1;
			this.BibleVersionsRegion1.SelectedIndex = this.InRegion1;
			this.BibleVersionsRegion2.SelectedIndex = this.InRegion2;
		}
		private void LoadBibleList(ref ComboBox InBibleList)
		{
			InBibleList.Items.Clear();
			InBibleList.Items.Add("");
			for (int i = 0; i <= gf.HB_TotalVersions - 1; i++)
			{
				InBibleList.Items.Add(gf.HB_Versions[i, 1] + " - " + gf.HB_Versions[i, 2]);
			}
		}
		private void BtnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
			base.Close();
		}
		private void BtnOK_Click(object sender, EventArgs e)
		{
			if (this.ValidateVersionOptions())
			{
				if (!(this.BibleVersionsRegion1.SelectedIndex == this.InRegion1 & this.BibleVersionsRegion2.SelectedIndex == this.InRegion2))
				{
					this.BuildNewIDString();
				}
				base.DialogResult = DialogResult.OK;
				base.Close();
			}
		}
		private bool ValidateVersionOptions()
		{
			bool result;
			if (this.BibleVersionsRegion1.SelectedIndex == 0)
			{
				MessageBox.Show("You must select a Bible Version for Region 1");
				result = false;
			}
			else
			{
				result = true;
			}
			return result;
		}
		private void BuildNewIDString()
		{
			string text = "";
			string displayNameOnly = gf.GetDisplayNameOnly(ref gf.HB_Versions[this.BibleVersionsRegion1.SelectedIndex - 1, 4], false, true);
			if (this.BibleVersionsRegion2.SelectedIndex > 0)
			{
				text = gf.GetDisplayNameOnly(ref gf.HB_Versions[this.BibleVersionsRegion2.SelectedIndex - 1, 4], false, true);
			}
			gf.EditBible_IDString = string.Concat(new object[]
			{
				this.InIDStringFirstPart,
				';',
				displayNameOnly,
				';',
				text,
				';',
				this.InIDString
			});
			int num = gf.EditBible_Title.IndexOf('(');
			if (num > 0)
			{
				gf.EditBible_Title = gf.Trim(gf.Left(gf.EditBible_Title, num - 1));
			}
			if (text == "")
			{
				gf.EditBible_Title = gf.EditBible_Title + " (" + gf.HB_Versions[this.BibleVersionsRegion1.SelectedIndex - 1, 1] + ")";
			}
			else
			{
				string editBible_Title = gf.EditBible_Title;
				gf.EditBible_Title = string.Concat(new string[]
				{
					editBible_Title,
					" (",
					gf.HB_Versions[this.BibleVersionsRegion1.SelectedIndex - 1, 1],
					"/",
					gf.HB_Versions[this.BibleVersionsRegion2.SelectedIndex - 1, 1],
					")"
				});
			}
		}
		private void BtnOK_Click()
		{
		}
		private void BtnCancel_Click()
		{
		}
	}
}
